#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read()
{
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
            f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
void write(int x)
{
    if(x<0)
        putchar('-'),x=-x;
    if(x>9)
        write(x/10);
    putchar('0'+x%10);
}
const int N=1e5+5;
int n,m,l,V,tot,c[N];
pair<int,int> p[N];
struct CAR
{
    int d,v,a;
}car[N];
double a[N];
bool cmp(pair<int,int>& x,pair<int,int>& y)
{
    if(x.second==y.second)
        return x.first>y.first;
    return x.second<y.second;
}
void add(int x)
{
    while(x<N)
    {
        c[x]++;
        x+=x&-x;
    }
}
int ask(int x)
{
    int ans=0;
    while(x)
    {
        ans+=c[x];
        x-=x&-x;
    }
    return ans;
}
void solve()
{
    memset(c,0,sizeof(c));
    n=read(),m=read(),l=read(),V=read();
    tot=0;
    for(int i=1;i<=n;i++)
        car[i].d=read(),car[i].v=read(),car[i].a=read();
    for(int i=1;i<=m;i++)
        a[i]=read();
    for(int i=1;i<=n;i++)
    {
        if(!car[i].a)
        {
            if(car[i].v<=V)
                continue;
            int tmp=lower_bound(a+1,a+m+1,car[i].d)-a;
            if(tmp<=m)
                p[++tot]={tmp,m};
        }
        else if(car[i].a>0)
        {
            double t;
            int pos;
            if(car[i].v<=V)
            {
                t=double(V-car[i].v)/((double)(car[i].a));
                t=(double)car[i].v*t+0.5*car[i].a*t*t+(double)car[i].d;
                pos=upper_bound(a+1,a+m+1,t)-a;
            }
            else
            {
                pos=lower_bound(a+1,a+m+1,car[i].d)-a;
            }
            if(pos&&pos<=m)
                p[++tot]={pos,m};//,cout<<i<<' '<<pos<<" "<<m<<endl;
        }
        else
        {
            if(car[i].v<=V)
                continue;
            double t=(double)(V-car[i].v)/((double)(car[i].a));
       //     cout<<t<<endl;
            t=(double)car[i].v*t+0.5*car[i].a*t*t+(double)car[i].d;
         //   cout<<t<<endl;
            int pos=lower_bound(a+1,a+m+1,t)-a-1,l=lower_bound(a+1,a+m+1,car[i].d)-a;
            if(pos&&l<=pos)
                p[++tot]={l,pos};//,cout<<i<<" "<<l<<' '<<pos<<endl;
        }
    }
    sort(p+1,p+tot+1,cmp);
    int ans=0;
    for(int i=1;i<=tot;i++)
    {
      //  cout<<p[i].first<<' '<<p[i].second;
        if(ask(p[i].second)==ask(p[i].first-1))
            add(p[i].second),ans++;
    }
    write(tot);
    putchar(' ');
    write(m-ans);
    puts("");
}
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int dd=read();
    while(dd--)
    {
        solve();
    }
    return 0;
}
